// call groovy expressions from Java code
def binding = new Binding();
binding.setVariable("foo", new Integer(2));
def shell = new GroovyShell(binding);

def ret = shell.evaluate(request.getReader());

out << ret
response.setContentType("application/json")
